<template>
	<view class="healthRecords">
		<view class="healthRecords_item healthRecords_jiyinbaogao">
			<view class="healthRecords_item_content">
				<u-image width="90rpx" height="90rpx"
					src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/13/2f9df2d77236469c844fb9344ff531d3.png"
					mode="scaleToFill" />
				<view class="healthRecords_item_content_desc">
					<text class="healthRecords_item_content_desc_text1">基因报告</text>
					<text class="healthRecords_item_content_desc_text2">查询基因报告</text>
				</view>
			</view>
			<view><text class="healthRecords_item_content_desc_text1">{{total}}份</text></view>
		</view>

		<view class="healthRecords_item healthRecords_qitabaogao">
			<view class="healthRecords_item_content">
				<u-image width="90rpx" height="90rpx"
					src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/13/837fd4d70f124525889ae2b2b0d84605.png"
					mode="scaleToFill" />
				<view class="healthRecords_item_content_desc">
					<text class="healthRecords_item_content_desc_text1">其他报告</text>
					<text class="healthRecords_item_content_desc_text2">{{
                            authority === "salesman" ? "查询" : "上传"
                        }}其他报告</text>
				</view>
			</view>
			<view><text class="healthRecords_item_content_desc_text1">{{otherTotal}}份</text></view>
		</view>
	</view>
</template>

<script>
	import { reportBaseUrl } from "@/config/tendIdConfig.js";
	import md5 from "@/js_sdk/js-md5/src/md5.js";
	import store from "@/store";
	let customerPhone;

	export default {
		components: {},
		data() {
			return {
				authority: this.$store.getters?.authority ?? "customer",
				appKey: process.env.NODE_ENV === "development" ?
					"test" : "app65026a842ab4e",
				apiSecret: process.env.NODE_ENV === "development" ?
					"test" : "1D73FEE27CB91463436FFD1B3D425C94",
					
				
				total:'0',
				otherTotal:'0'
			};
		},
		onLoad(options) {
			customerPhone = options?.customerPhone;
		},
		methods: {
			toGeneReport() {
				this.$u.route({
					url: "pages_my/gene_report/index",
				});
			},
			toOtherReport() {
				this.$u.route({
					url: "pages_my/other_report/index",
				});
			},
			login() {
				store.dispatch("REPORT_LOGIN", {
					customerPhone
				});
				
				this.queryList()
				this.otherQueryList()
			},

			queryList() {
				const that = this;
				uni.request({
					url: `${reportBaseUrl}/web/order_report/reportList`,
					header: {
						H5accessToken: that.$store.state.reportToken,
					},
					method: "POST",
					data: {
						pageNum: 1,
						pageSize:1000,
					},
					success(result) {
						if (result.data.code === 200) {
							that.total = result.data.data.total;
							console.log(that.total,'total>>>>');
						} else {
							uni.showToast({
								title: result.data.msg,
								icon: "none",
							});
						}
					},
					fail(error) {
						console.log(error);
					},
				});
			},
			otherQueryList() {
				const that = this;
				uni.request({
					url: `${reportBaseUrl}/web/other_report/reportList`,
					header: {
						H5accessToken: that.$store.state.reportToken,
					},
					method: "POST",
					data: {
						pageNum: 1,
						pageSize:1000,
					},
					success(result) {
						if (result.data.code === 200) {
							that.otherTotal = result.data.data.total;
							console.log(that.otherTotal,'otherTotal>>>>');
						} else {
							uni.showToast({
								title: result.data.msg,
								icon: "none",
							});
						}
					},
					fail(error) {
						console.log(error);
					},
				});
			},
			
		},
		watch: {},

		onShow() {
			this.login();
		},
	};
</script>

<style lang="scss" scoped>
	.healthRecords {
		width: 100%;
		height: auto;
		padding: 32rpx;
		box-sizing: border-box;

		&_jiyinbaogao {
			background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/fcd51504385d4ff09c22637f219025ec.png");
		}

		&_qitabaogao {
			background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/63df876c95614b24af97aabb60901e1f.png");
		}

		&_item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			height: 196rpx;
			background-size: cover;
			background-repeat: no-repeat;
			border-radius: 10rpx;
			overflow: hidden;
			padding:0 74rpx;
			box-sizing: border-box;
			margin-bottom: 46rpx;

			&_content {
				display: flex;
				align-items: center;

				&_desc {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					height: 70rpx;

					&_text1 {
						font-size: 32rpx;
						font-weight: bold;
						color: #fff;
						line-height: 1;
					}

					&_text2 {
						font-size: 24rpx;
						color: #fff;
						line-height: 1;
					}
				}
			}
		}
	}
</style>